import {
	createRouter,
	createWebHistory,
	createWebHashHistory
} from 'vue-router'
import HomeView2 from '../views2/HomeView2.vue'
import Workflow from '../views/Workflow.vue'
import siteAdmin from '../views/siteAdmin.vue'
import AboutView from '../views/AboutView.vue'
import login from '../views/login.vue'
import siteB from '../views/site_b.vue'
import siteC from '../views/site_c.vue'
import siteD from '../views/site_d.vue'
import siteE from '../views/site_e.vue'

const router = createRouter({
	history: createWebHashHistory(
		import.meta.env.BASE_URL),
	routes: [{
		path: '/',
		name: 'home',
		component: HomeView2,
		meta: {
			title: '首页'
		},
		children: [
			{
				path: '/retention',
				name: 'retention',
				component: () => import('../views2/retention.vue'),
			},
			{
				path: '/createSite',
				name: 'createSite',
				component: () => import('../views2/createSite.vue'),
			},
			{
				path: '/siteRetention',
				name: 'siteRetention',
				component: () => import('../views2/siteRetention.vue'),
			},
			{
				path: '/siteVerification',
				name: 'siteVerification',
				component: () => import('../views2/siteVerification.vue'),
			},
			{
				path: '/siteOperation',
				name: 'siteOperation',
				component: () => import('../views2/siteOperation.vue'),
			},
			{
				path: '/siteGiftConfig',
				name: 'siteGiftConfig',
				component: () => import('../views2/siteGiftConfig.vue'),
			},
			{
				path: '/siteStockConfig',
				name: 'siteStockConfig',
				component: () => import('../views2/siteStockConfig.vue'),
			},
			{
				path: '/siteConfig',
				name: 'siteConfig',
				component: () => import('../views2/siteConfig.vue'),
			},
			{
				path: '/siteProjects',
				name: 'siteProjects',
				component: () => import('../views2/siteProjects.vue'),
			},
			{
				path: '/general',
				name: 'general',
				component: () => import('../views2/general.vue'),
			},
			{
				path: '/toolManage',
				name: 'toolManage',
				component: () => import('../views/toolManage.vue'),
			},
			{
				path: 'Workflow',
				component: () => import('../views/Workflow.vue'),
				meta: {
					title: '工作流创建'
				},
			},
			{
				path: 'siteAdmin',
				component: () => import('../views2/adminManagement.vue'),
				meta: {
					title: '账号管理'
				},
			},
			{
				path: '/about',
				name: 'about',
				component: () => import('../views/AboutView.vue'),
			},
			{
				path: '/site_b',
				name: 'site_b',
				component: () => import('../views/site_b.vue'),
			},
			{
				path: '/site_c',
				name: 'site_c',
				// component: () => import('../views/site_c.vue'),
				redirect: '/site_c',
				meta: {
					title: '报告查看'
				},
				children: [{
					path: '/site_c',
					component: () => import('../views/site_c.vue'),
				},
				{
					path: '/site_c/reportList',
					component: () => import('../views/reportList.vue'),
					meta: { title: '报告详情' }
				}, {
					path: '/site_c/setShowcase',
					component: () => import('../views/setShowcase.vue'),
					meta: { title: '布展' }
				}, {
					path: '/site_c/setlookcase',
					component: () => import('../views/setlookcase.vue'),
					meta: { title: '看展' }
				}, {
					path: '/site_c/setOutcase',
					component: () => import('../views/setOutcase.vue'),
					meta: { title: '撤展' }
				}, {
					path: '/site_c/setSummarize',
					component: () => import('../views/setSummarize.vue'),
					meta: { title: '总结' }
				}, {
					path: '/site_c/setDevice',
					component: () => import('../views/setDevice.vue'),
					meta: { title: '展具' }
				}, {
					path: '/site_c/setCompent',
					component: () => import('../views/setCompent.vue'),
					meta: { title: '竞品' }
				}]
			},

			{
				path: '/site_d',
				name: 'site_d',
				component: siteD
			},
			{
				path: '/site_e',
				name: 'site_e',
				component: siteE
			},
		
		]
	},
	{
		path: '/login',
		name: 'login',
		component: () => import('../views/login.vue'),
		meta: { isPublic: true }
	},
	]
})
// 做路由守卫，登录限制
router.beforeEach((to, from, next) => {
	if (!to.meta.isPublic && !(localStorage.getItem('openid') != null)) {
		return next('/login')
	}
	next()
})


export default router
